/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package sysdental.manager;

import java.sql.ResultSet;
import java.util.ArrayList;
import java.util.List;
import javax.swing.JOptionPane;
import sysdental.common.GestionDB;
import sysdental.to.TratamientoTO;

/**
 *
 * @author Alumno
 */
public class TratamientoManager {
    GestionDB cnn=new GestionDB();
    
    //-------------------------Método para listar tratamientos ------------------
    public List<TratamientoTO> listar() throws Exception{
        ArrayList data=new ArrayList();
        String sql="SELECT * FROM sd_tratamiento";
        try{
         cnn.conectar();
         ResultSet rs=cnn.ejecutarConsulta(sql);
         while(rs.next()){
             TratamientoTO p=new TratamientoTO();
             p.setId_tratamiento(rs.getString("id_tratamiento"));
             p.setDes_se(rs.getString("des_se"));
             p.setCos_se(rs.getString("cos_se"));
             data.add(p);
         }
         rs.close();
         cnn.desconectar();
        }catch(Exception e){
            JOptionPane.showMessageDialog(null, e.getMessage());
        }
    return data;            
    }
    
}
